/**
 * 序列号
 */
import { axios } from '@/utils/request'
import store from '@/store'

const hardcodeUrl = ''

const api = {
  serialNum: 'techserialnum', // 分类
  serialSection: 'techdefinesection', // 区段定义
  serialOrder: 'order-serial-num',
  preview: 'techserialnum/generate-test'
}
/**
 * 获取序列号分类
 * @param {*} params
 */
export function getSerialTree (params) {
  return axios({
    url: api.serialNum + '/tree-list',
    method: 'get',
    params
  })
}

export function getSerialRule (params) {
  return axios({
    url: api.serialNum + '/info',
    method: 'get',
    params
  })
}

export function addSerialRule (data) {
  return axios({
    url: api.serialNum,
    method: 'post',
    data
  })
}

export function updateSerialRule (data) {
  return axios({
    url: api.serialNum,
    method: 'put',
    data
  })
}

export function delSerialRule (params) {
  return axios({
    url: api.serialNum,
    method: 'delete',
    params
  })
}

export function validateSerialRule (params) {
  return axios({
    url: api.serialNum + '/unique',
    method: 'get',
    params
  })
}

/**
 * 获取序列号区段
 * @param {*} params
 */
export function getSerialSectionList (params) {
  return axios({
    url: api.serialSection + '/list',
    method: 'get',
    params
  })
}

export function addSerialSection (data) {
  return axios({
    url: api.serialSection,
    method: 'post',
    data
  })
}

export function updateSerialSection (data) {
  return axios({
    url: api.serialSection,
    method: 'put',
    data
  })
}

export function delSerialSection (params) {
  return axios({
    url: api.serialSection,
    method: 'delete',
    params
  })
}

export function generateSerial (data) {
  return axios({
    url: api.serialOrder,
    method: 'post',
    data
  })
}

export function previewSerail (data) {
  return axios({
    url: api.preview,
    method: 'post',
    data
  })
}

export function getGenerateList (params) {
  return axios({
    url: api.serialOrder + '/list',
    method: 'get',
    params
  })
}
